import request from '../utils/request'

// 获取排课列表
export function getScheduleList() {
  return request({
    url: '/schedule/list',
    method: 'get'
  })
}

// 分页获取排课列表（支持搜索参数）
export function getSchedulePage(params) {
  // params: { page, pageSize, semester, courseName, teacherName, clazzName, scheduleType, status }
  return request({
    url: '/schedule/page',
    method: 'get',
    params: params  // 传递所有参数
  })
}

// 智能排课
export function intelligentSchedule(semester) {
  return request({
    url: `/schedule/intelligent/${semester}`,
    method: 'post'
  })
}

// 高级智能排课 - /advanced-schedule/execute
export function executeAdvancedSchedule(data) {
  return request({
    url: '/advanced-schedule/execute',
    method: 'post',
    data
  })
}

// 高级排课 - 可选班级
export function getAdvancedClazzes() {
  return request({
    url: '/advanced-schedule/available-clazzes',
    method: 'get'
  })
}

// 高级排课 - 可选课程
export function getAdvancedCourses() {
  return request({
    url: '/advanced-schedule/available-courses',
    method: 'get'
  })
}

// 高级排课 - 默认参数
export function getAdvancedDefaultParams() {
  return request({
    url: '/advanced-schedule/default-params',
    method: 'get'
  })
}

// 高级排课 - 参数校验
export function validateAdvancedParams(data) {
  return request({
    url: '/advanced-schedule/validate-params',
    method: 'post',
    data
  })
}

// 添加排课
export function addSchedule(schedule) {
  return request({
    url: '/schedule/add',
    method: 'post',
    data: schedule
  })
}

// 更新排课
export function updateSchedule(schedule) {
  return request({
    url: '/schedule/update',
    method: 'put',
    data: schedule
  })
}

// 删除排课
export function deleteSchedule(id) {
  return request({
    url: `/schedule/delete/${id}`,
    method: 'delete'
  })
}

// 获取教师课表
export function getTeacherSchedule(teacherId, semester) {
  return request({
    url: `/schedule/teacher/${teacherId}/${semester}`,
    method: 'get'
  })
}

// 获取班级课表
export function getClassSchedule(clazzId, semester) {
  return request({
    url: `/schedule/class/${clazzId}/${semester}`,
    method: 'get'
  })
}

// 获取教室课表
export function getClassroomSchedule(classroomId, semester) {
  return request({
    url: `/schedule/classroom/${classroomId}/${semester}`,
    method: 'get'
  })
}

// 检查排课冲突
export function checkScheduleConflict(schedule) {
  return request({
    url: '/schedule/check-conflict',
    method: 'post',
    data: schedule
  })
}

// 高级智能排课 - 带选项
export function intelligentScheduleWithOptions(data) {
  return request({
    url: '/schedule/intelligent-advanced',
    method: 'post',
    data
  })
}

// 遗传算法排课
export function intelligentScheduleGA(data) {
  return request({
    url: '/schedule/intelligent-ga',
    method: 'post',
    data
  })
}

// 检查班级周课时限制
export function checkClassWeeklyLimit(clazzId, semester) {
  return request({
    url: `/schedule/check-weekly-limit/${clazzId}`,
    method: 'get',
    params: { semester }
  })
}



